<?php /* @var $customer Customer */ ?>

<div class="center_title">
    <?php echo __('Confirm cart') ?>
</div>

<?php if($sf_flash->has('success')): ?>
    <?php echo __($sf_flash->get('success')); ?>
<?php endif; ?>

    <?php if( $sf_request->hasErrors() ): ?>
        <span class="error"><?php echo __('The form is not valid because it contains some errors.') ?></span><br /><br />
    <?php endif; ?>

<div class="center_text">
    <div class="text_item">

    <?php echo form_tag('cart/confirmform'); ?>
        <table border="0" class="confirm_cart">
        <?php echo input_hidden_tag('receipt', $receipt->getId())?>
<!--   /////////////////////////name///////////////////////////////////     -->
        <?php if( $sf_request->hasError('name') ): ?>
            <tr>
                <td>&nbsp;</td>
                <td><span class="error"><?php echo $sf_request->getError('name') ?></span></td>
            </tr>
        <?php endif; ?>
        <tr>
            <td><?php echo __('name'); ?>:</td>
            <td><?php echo input_tag('name'
                                    , $customer?$customer->getName():''
                                    , array('class' => 'inputSMALL')); ?></td>
        </tr>
        <!--   /////////////////////////surname///////////////////////////////////     -->
        <?php if( $sf_request->hasError('surname') ): ?>
            <tr>
                <td>&nbsp;</td>
                <td><span class="error"><?php echo $sf_request->getError('surname') ?></span></td>
            </tr>
        <?php endif; ?>
        <tr>
            <td><?php echo __('surname'); ?>:</td>
            <td><?php echo input_tag('surname'
                                    , $customer?$customer->getSurname():1
                                    , array('class' => 'inputSMALL')); ?></td>
        </tr>
        <!--   ///////////////////////////phone////////////////////////////////     -->
        <?php if( $sf_request->hasError('phone') ): ?>
            <tr>
                <td>&nbsp;</td>
                <td><span class="error"><?php echo $sf_request->getError('phone') ?></span></td>
            </tr>
        <?php endif; ?>
        <tr>
            <td><?php echo __('phone'); ?>:</td>
            <td><?php echo input_tag('phone'
                                    , $customer?$customer->getPhoneNr():''
                                    , array('class' => 'inputSMALL')); ?></td>
        </tr>
        <!--   ///////////////////////////email////////////////////////////////     -->
        <?php if( $sf_request->hasError('email') ): ?>
            <tr>
                <td>&nbsp;</td>
                <td><span class="error"><?php echo $sf_request->getError('email') ?></span></td>
            </tr>
        <?php endif; ?>
        <tr>
            <td><?php echo __('email'); ?>:</td>
            <td><?php echo input_tag('email'
                                    , $customer?$customer->getEmail():''
                                    , array('class' => 'inputSMALL')); ?></td>
        </tr>
<!--   ///////////////////////////is_company////////////////////////////////     -->
        <tr>

            <td><?php echo __('is company'); ?>:</td>
            <?php if( $customer ):?>
                <?php if( $customer->getIsCompany() == true ):?>
                    <td><?php echo checkbox_tag('is_company', true, true); ?></td>
                <?php else: ?>
                    <td><?php echo checkbox_tag('is_company', true, false); ?></td>
                <?php endif; ?>
            <?php else: ?>
                <td><?php echo checkbox_tag('is_company', true, false); ?></td>
            <?php endif; ?><!--
            <td><?php echo checkbox_tag('is_company', true, $customer?$customer->getIsCompany():array('class' => 'inputSMALL')) ?></td>
        --></tr>
        <!--   ///////////////////////////company name////////////////////////////////     -->
        <?php if( $sf_request->hasError('company_name') ): ?>
            <tr>
                <td>&nbsp;</td>
                <td><span class="error"><?php echo $sf_request->getError('company_name') ?></span></td>
            </tr>
        <?php endif; ?>
        <tr>
            <td><?php echo __('company name'); ?>:</td>
            <td><?php echo input_tag('company_name', $customer?$customer->getCompanyName():'', array('class' => 'inputSMALL')); ?></td>
        </tr>
        <!--   ///////////////////////////company nr////////////////////////////////     -->
        <?php if( $sf_request->hasError('company_nr') ): ?>
            <tr>
                <td>&nbsp;</td>
                <td><span class="error"><?php echo $sf_request->getError('company_nr') ?></span></td>
            </tr>
        <?php endif; ?>
        <tr>
            <td><?php echo __('companynr'); ?>:</td>
            <td><?php echo input_tag('company_nr', $customer?$customer->getCompanyNr():'', array('class' => 'inputSMALL')); ?></td>
        </tr>
        <!--   ///////////////////////////fiscal Conde////////////////////////////////     -->
        <?php if( $sf_request->hasError('fiscal_code') ): ?>
            <tr>
                <td>&nbsp;</td>
                <td><span class="error"><?php echo $sf_request->getError('fiscal_code') ?></span></td>
            </tr>
        <?php endif; ?>
        <tr>
            <td><?php echo __('fiscal code'); ?>:</td>
            <td><?php echo input_tag('fiscal_code', $customer?$customer->getFiscalCode():'', array('class' => 'inputSMALL')); ?></td>
        </tr>
<!--   ///////////////////////////address////////////////////////////////     -->
        <?php if( $sf_request->hasError('countrycode') ): ?>
            <tr>
                <td>&nbsp;</td>
                <td><span class="error"><?php echo $sf_request->getError('countrycode') ?></span></td>
            </tr>
        <?php endif; ?>
        <tr>
            <td><?php echo __('Country'); ?>:</td>
            <td >
            <?php use_helper('Javascript') ?>
            <?php echo select_tag('countrycode'
                                , SymHelper::AOptionsForCountrySelect(Countries::getCountriesEu()
                                                                    , $customer->getCountrycode()?$customer->getCountrycode():'LT')
                                , array('onchange' => 'onCountrySelected()')) ?>
           
            <?php //echo select_country_tag('countrycode', $customer->getCountrycode()?$customer->getCountrycode():'LT') ?>
            </td>
        </tr>
            
        <?php if( $sf_request->hasError('city') ): ?>
            <tr>
                <td>&nbsp;</td>
                <td><span class="error">
                    <?php echo $sf_request->getError('city') ?>
                </span></td>
            </tr>
        <?php endif; ?>
        <tr>
            <td><?php echo __('City'); ?>:</td>
            <td><?php echo input_tag('city'
                                    , $customer?$customer->getCity():''
                                    , array('class' => 'inputSMALL')); ?></td>
        
        </tr>
        <?php if( $sf_request->hasError('zip') ): ?>
            <tr>
                <td>&nbsp;</td>
                <td><span class="error">
                    <?php echo $sf_request->getError('zip') ?>
                </span></td>
            </tr>
        <?php endif; ?>
        <tr>
            <td><?php echo __('ZIP'); ?>:</td>
            <td><?php echo input_tag('zip'
                                    , $customer?$customer->getZip():''
                                    , array('class' => 'inputSMALL')); ?></td>
        
        </tr>
        <?php if( $sf_request->hasError('street') ): ?>
            <tr>
                <td>&nbsp;</td>
                <td><span class="error">
                    <?php echo $sf_request->getError('street') ?>
                </span></td>
            </tr>
        <?php endif; ?>
        <tr>
            <td><?php echo __('Street and house/flat'); ?>:</td>
            <td><?php echo input_tag('street'
                                    , $customer?$customer->getStreet():''
                                    , array('class' => 'inputSMALL')); ?></td>
        
        </tr>
        
        
        <tr>
            <td><?php echo __('Delivery'); ?>:</td>
            <td class="update", id="update">
            <?php echo select_tag('shipping'
                                , options_for_select(Shipping::getApprovedShippings($customer->getCountrycode()?$customer->getCountrycode():'LT'))
                                , array('class' => '')) ?>
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>
                <?php echo submit_tag(__('confirm'), array('class' => 'login_submit')); ?>&nbsp;&nbsp;&nbsp;
                <?php echo link_to(
                                image_tag(
                                    'delete.png'
                                    , array(
                                        'alt' => __('reset form')
                                        , 'title' => __('reset form')
                                        , 'style' => 'margin-bottom: -4px;'
                                    )
                                )
                            , 'cart/confirm?reset=1'
                        ) ?>
                <?php echo link_to(__('reset form'), 'cart/confirm?reset=1') ?>
            </td>
        </tr>
        </table>
    </form>
<!--    <form action='expresscheckout.php' METHOD='POST'>-->
<!--<input type='image' name='submit' src='https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif' border='0' align='top' alt='Check out with PayPal'/>-->
<!--</form>-->
    </div>
</div>
<script type="text/javascript">
function onCountrySelected()
{
    jQuery.ajax({
        type: "post"
        , data: ({'countryId' : jQuery('#countrycode').val()})
        , dataType: "html"
        , url: "/st.php/lt/cart/getshipping"
        , success: function(data) { jQuery('#update').html(data); }
    });
}
</script>
